package com.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.bean.LoginBean;

public class Login extends AbstractAction {

	private static final String LOGIN_URL					= "/programs/login/login.jsp";
	private static final String MAIN_URL					= "/programs/main/main.jsp";
	private static final String LOGOUT_URL					= "/programs/usuarios/list.jsp";
	
	private static final String LOGIN_ACTION 				= "login";
	private static final String LOGOUT_ACTION 				= "logout";
	
	@Override
	public String doAction(HttpServletRequest req, HttpServletResponse res) {
		// TODO Auto-generated method stub
		String action=req.getParameter("action");
		LoginBean bean=new LoginBean();
		//req.getSession().setAttribute("bean",bean);
		if(LOGIN_ACTION.equals(action)){
			if(bean.login(req)){
				return MAIN_URL;
			}else{
				return LOGIN_URL;
			}
		}
		if(LOGOUT_ACTION.equals(action)){
			return LOGIN_URL;
		}
		return null;
	}

}
